#include "StdAfx.h"
#include "TaskStateObserver.h"

CTaskStateObserver::CTaskStateObserver(void)
{
}

CTaskStateObserver::~CTaskStateObserver(void)
{
}

HRESULT CTaskStateObserver::RegisterObserver(ITaskEvent* pEvent)
{
	CAutoLock m_AutoLock(m_csTaskState);
	m_pEventList.push_back(pEvent);
	return S_OK;
}

HRESULT CTaskStateObserver::UnRegisterObserver(ITaskEvent* pEvent)
{
	CAutoLock m_AutoLock(m_csTaskState);
	for(std::vector<ITaskEvent*>::iterator itor = m_pEventList.begin();
		itor != m_pEventList.end();++itor)
	{
		if((*itor) == pEvent)
		{
			m_pEventList.erase(itor);
			break;
		}
	}
	return S_OK;
}